<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户众筹详情</title>
    <script src="../commonCss.js"></script>
    <script src="../commonJs.js"></script>
    <link rel="stylesheet" href="../../css/common.css">
</head>
<style type="text/css">
    tr{
        line-height: 35px
    }

    font{
        cursor: pointer;
    }
    #viewCon span{
        padding-left:3px;
    }
    .basicinfo{
        font-weight: bold;
        padding-right: 13px;
    }
</style>

<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <ol class="breadcrumb">
        <li><a href="crowdfundList.html">用户众筹列表</a></li>
        <li class="active">用户众筹详情</li>
    </ol>

    <ul class="nav nav-tabs " style="padding-top: 15px;padding-left: 10px;">
        <li class="active" onclick="getCrowdDetail()"><a href="#tab_1" data-toggle="tab" aria-expanded="false" style="font-size: 16px;">众筹基本信息</a></li>
        <li class="" onclick="getCrowdMoneyDetail()"><a href="#tab_2" data-toggle="tab" aria-expanded="false" style="font-size: 16px;">筹款记录</a></li>
    </ul>

    <div class="tab-content" style="padding:15px">
        <!-- 众筹详情 -->
        <div class="tab-pane active" id="tab_1">
            <table>
                <tr>
                    <td class="basicinfo" align="right" style="width: 10%;">众筹标题：</td>
                    <td id="title" ></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">众筹类型：</td>
                    <td id="type" align="left"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">筹集金额：</td>
                    <td id="targetMoney"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">已筹金额：</td>
                    <td id="currentMoney"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">发单银行卡：</td>
                    <td id="bankCard"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">收款银行卡：</td>
                    <td id="receiptBankCard"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">用户昵称：</td>
                    <td id="username"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">用户账号：</td>
                    <td id="account"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">账单金额：</td>
                    <td id="billMoney"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right" >账单图片：</td>
                    <td>
                        <img id="img" style="border:1px dashed #ddd;width:150px;" onclick="maxPic(this.src)">
                        <img id="img2" style="border:1px dashed #ddd;width:150px;" onclick="maxPic(this.src)">
                        <img id="img3" style="border:1px dashed #ddd;width:150px;" onclick="maxPic(this.src)">
                    </td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">账单类型：</td>
                    <td id="billType"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">开始时间：</td>
                    <td id="startTime"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">结束时间：</td>
                    <td id="endTime"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">状态：</td>
                    <td id="status"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">打款订单号：</td>
                    <td id="orderNum"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">服务费：</td>
                    <td id="serviceMoney"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">筹集原因：</td>
                    <td >
                        <textarea cols="138" rows="4" id="reason" readonly="readonly"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">信用扣分：</td>
                    <td id="creditPoint"></td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">扣分原因：</td>
                    <td >
                        <textarea cols="138" rows="4" id="creditReason" readonly="readonly"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="basicinfo" align="right">驳回原因：</td>
                    <td >
                        <textarea cols="138" rows="4" id="rejectResion" readonly="readonly"></textarea>
                    </td>
                </tr>
            </table>
        </div>

        <!--筹款记录-->
        <div class="tab-pane" id="tab_2">
            <section class="content" >
                <div class="row">
                    <div class="col-xs-12" style="padding-left: inherit;">
                        <div class="box-header">
                            <form class="form-inline">
                                <div class="form-group">
                                    <label>查询:</label>
                                    <input type="text" id="searchCrowd" class="form-control" placeholder="输入用户账号/互助金额搜索"/>
                                </div>

                                <div class="form-group">
                                    <button type="button" onclick="getCrowdMoneyDetail();"  class="btn btn-block btn-primary">搜索</button>
                                </div>
                            </form>

                        </div>
                        <!-- 数据列表展示 -->
                        <div class="box-body" style="height:100%;">
                            <table id="crowdfundList" class="table table-bordered table-hover" >
                                <thead>
                                <tr>
                                    <th>用户账号</th>
                                    <th>用户昵称</th>
                                    <th>用户手机号</th>
                                    <th>互助金额</th>
                                    <th>互助时间</th>
                                </tr>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>

    <!-- 【图片点击放大】弹出窗内容 -->
    <div class="modal" id="picMonthDialog" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" >
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                   <h4 class="modal-title" align="center">账单</h4>
                </div>
                <img id="maxPic" width="100%">
            </div>
        </div>
    </div>
</section>


<!-- page script -->
<script>
    //获取众筹单id
    var crdId = getUrlParam("crdId");
    $(document).ready(function() {
        //加载数据
        getCrowdDetail();

    });

    function getCrowdDetail() {
        $.ajax({
            type:"POST",
            url:"/crowdfund/getCrowdfundById",
            async : true,//默认就是true
            dataType:"json",
            data:{id : crdId},
            success:function(result){
                if(result != null){
                   result = result.data.crowdfund;
                   $("#title").html(result.title);
                   $("#targetMoney").html(result.targetMoney);
                   $("#currentMoney").html(result.currentMoney);
                   $("#account").html(result.userAccount);
                   $("#username").html(result.username);
                   $("#bankCard").html(result.cardNum + "（" + result.bankName + "）");
                   if (result.receiptCardNum) {
                      $("#receiptBankCard").html(result.receiptCardNum + "（" + result.receiptBankName + "）");
                   } else {
                      $("#receiptBankCard").html("");
                   }
                    $("#billMoney").html(result.billMoney);
                    result.billType == 1? $("#billType").html("需好友担保") : $("#billType").html("系统分配的");
                    $("#startTime").html(toDate(result.startTime).format('yyyy-MM-dd HH:mm:ss'));
                    $("#endTime").html(toDate(result.endTime).format('yyyy-MM-dd HH:mm:ss'));
                    $("#serviceMoney").html(result.serviceMoney);

                    $("#creditPoint").html(result.creditPoint);
                    $("#creditReason").html(result.creditReason);
                    $("#rejectResion").html(result.rejectResion);

                    //清除之前的图片缓存
                    $("#img").attr("src","");
                    $("#img2").attr("src","");
                    $("#img3").attr("src","");
                    var len =result.img.split("$");
                    if(len != 0){
                        $("#img").attr("src",len[0]);
                        if(len.length > 1){
                            $("#img2").attr("src",len[1]);
                            $("#img2").show();
                        }else{
                            $("#img2").hide();
                        }
                        if(len.length > 2){
                            $("#img3").attr("src",len[2]);
                            $("#img3").show();
                        }else{
                            $("#img3").hide();
                        }
                    }else{
                        $("#img").hide();
                        $("#img2").hide();
                        $("#img3").hide();
                    }

                    if(result.type == 1){
                        $("#type").html("江湖救急");
                    }else if(result.type == 2){
                        $("#type").html("还房贷");
                    }else if(result.type == 3){
                        $("#type").html("还车贷");
                    }else if(result.type == 4){
                        $("#type").html("还信用卡");
                    }else if(result.type == 5){
                        $("#type").html("求助");
                    }

                    if(result.status == 0){
                        $("#status").html("审核中");
                    }else if(result.status == 1){
                        $("#status").html("进行中(审核通过)");
                    }else if(result.status == 2){
                        $("#status").html("付款中");
                    }else if(result.status == 3){
                        $("#status").html("已结束");
                    }else if(result.status == 4){
                        $("#status").html("进行中(被扣分)");
                    }else if(result.status == 5){
                        $("#status").html("已驳回");
                    }else if(result.status == 6){
                        $("#status").html("已失效");
                    }else if(result.status == 21){
                        $("#status").html("付款中(暂停付款)");
                    }
                    $("#orderNum").html(result.orderNum);
                    $("#reason").html(result.reason);

                }
            },
            failure:function(result) {
                layer.msg('网络错误！');
            },
        });
    }

    function getCrowdMoneyDetail(){
        var searchCrowd = $("#searchCrowd").val();
        var table = $('#crowdfundList').DataTable({
            "destroy": true,   //可以重新初始化，用于搜索
            "lengthChange": false,
            "ordering": false,   //排序
            "info": true,		   //
            "autoWidth": false,   //宽度自动
            "paging": true,      //分页
            "searching": false,  //全局搜索关闭
            "processing": true,  //开启显示‘正在加载.../processing’
            "serverSide":true,   //true代表后台处理分页，false代表前台处理分页
            "ajax" :  {
                url:"/crowdfund/getCrowdfundDetailList",
                type:"post",
                data:{
                    crowdfundId : crdId,
                    keyWord : searchCrowd
                },
                dataSrc: function (myJson) {
                    return myJson.data.data;
                }
            },
            //参数显示
            "columns": [
                {"data": "acount", 'sClass': "text-center",'width': '8%',
                    "render": function ( data, type, full, meta ) {
                        if (data == null){
                            return "微信用户"
                        } else{
                            return data;
                        }
                    }
                },
                {"data": "userName", 'sClass': "text-center",'width': '8%'},
                {"data": "mobile", 'sClass': "text-center",'width': '10%'},
                {"data": "money", 'sClass': "text-center",'width': '6%'},
                {"data": "createTime", 'sClass': "text-center",'width': '10%',
                    "render": function ( data, type, full, meta ) {
                        return toDate(data).format('yyyy-MM-dd HH:mm:ss');
                    }
                }
            ],

            //是否开启主题
            "bJQueryUI": true,
            "oLanguage": {    // 语言设置
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "sZeroRecords": "没有检索到数据",
                "sSearch": "检索:",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                }
            }
        });
    }

    //众筹信息审核通过
    function checkPass(id){
        if(confirm("确定审核通过该众筹单？")){
            submitCheck(id,1);
        }
    }
    //提交审核通过
    function submitCheck(id,status) {
        $.ajax({
            url:"/crowdfund/editCrowdfundStatus",
            type:"POST",
            async : true,//默认就是true
            dataType:"json",
            data:{id : id,status : status},
            success:function(data) {
                layer.msg(data.msg);
                showUserCrowdfund();
            }
        });
    }
    //上传的账单信息不通过，弹出扣分界面
    var cid ;
    function checkNotPass(crowdfundId){
        $("#punishDialog").modal("toggle");
        cid = crowdfundId;
    }

    //确定处罚扣分
    function confirmSubmit() {
        //1、通过审核
        submitCheck(cid,4);
        //2、进行信用分扣除
        $.ajax({
            url:"/crowdfund/editCreditScoreByUserId",
            type:"POST",
            async : true,//默认就是true
            dataType:"json",
            data:{
                userId : id ,
                score : $("#punishScore").val(),
                reason : $("#reason").val(),
                type : 5   //信用类型(1发红包 2互助 3登录 4其他 5违规)
            },
            success:function(data) {
                layer.msg(data.msg);
                $("#punishDialog").modal("toggle");
                showUserCrowdfund();
            }
        });
    }

    //查看众筹单筹款详情
    function viewDetail(id){
        window.location.href="user/userDetail.html?userId="+id;
    }

</script>
</body>
</html>
